home *** CD-ROM | disk | FTP | other *** search
- /****************************
-
- cDotsApp.c
-
- SUPERCLASS = CApplication
-
- Application methods for Dots
-
- *****************************/
-
- #include <CError.h>
- #include <Commands.h>
- #include <Constants.h>
- #include "cDotsApp.h"
- #include "cDotsDoc.h"
- #include "dotsTypes.h"
-
- /*** Class Constants ***/
- #define I_ABOUT 8 /* String index in STRcommon */
-
-
- /*** Globals ***/
- extern CError *gError; /* The global error handler */
- extern OSType gSignature; /* File creator signature */
-
- extern Pattern *dgPlayerPats;
-
- /********** I N I T I A L I Z A T I O N ********/
-
- /*** IDotsApp
- *
- * Initialize the application. Your initialization method should
- * at least call the inherited method. If your application class
- * defines its own instance variables or global variables, this
- * is a good place to initialize them.
- */
- void cDotsApp::IDotsApp(void)
- {
- /* Set moreMasters, rainyDayFund, creditLimit */
- CApplication::IApplication(4, 20480L, 2048L);
-
- /* Set the patterns associated with each player */
- BlockMove(ltGray, &dgPlayerPats[kPlayer1], sizeof(Pattern));
- BlockMove(dkGray, &dgPlayerPats[kPlayer2], sizeof(Pattern));
- }
-
-
- /*** SetUpFileParameters {OVERRIDE}
- *
- * Specify the kinds of files the application opens
- */
- void cDotsApp::SetUpFileParameters(void)
- {
- inherited::SetUpFileParameters(); /* Call the default method */
-
- gSignature = 'dots'; /* File creator */
-
- /* Set the number and types of files recognized */
- sfNumTypes = 1;
- sfFileTypes[0] = 'DATA';
- }
-
-
- /********** C O M M A N D ********/
-
- /*** DoCommand {OVERRIDE}
- *
- * Your application will probably handle its own commands.
- * Remember, the command numbers from 1-1023 are reserved.
- * The file Commands.h contains all the reserved commands.
- * Be sure to call the default method, so you can get
- * the default behvior for standard commands.
- */
- void cDotsApp::DoCommand(long theCommand)
- {
- switch (theCommand) {
-
- case cmdAbout:
- gError->PostAlert(STRcommon, I_ABOUT); /* Show the 'about' alert */
- break;
- default:
- inherited::DoCommand(theCommand);
- break;
- }
- }
-
- /********** D O C U M E N T ********/
-
- /*** CreateDocument {OVERRIDE}
- *
- * The user chose New from the File menu. Create a document and send it
- * a NewFile() message.
- */
- void cDotsApp::CreateDocument()
- {
- cDotsDoc *theDocument;
-
- theDocument = new(cDotsDoc);
- theDocument->IDotsDoc(this, TRUE);
- theDocument->NewFile();
- }
-
- /*** OpenDocument {OVERRIDE}
- *
- * Open… was chosen from the File menu. Create a document
- * and send it an OpenFile() message.
- *
- * The macSFReply is a good SFReply record that contains
- * the name and vRefNum of the file the user chose to open.
- */
- void cDotsApp::OpenDocument(SFReply *macSFReply)
- {
- cDotsDoc *theDocument;
-
- theDocument = new(cDotsDoc);
- theDocument->IDotsDoc(this, TRUE);
- theDocument->OpenFile(macSFReply);
- }